package smartbooks.ui.manager;

import java.util.ArrayList;
import smartbooks.ui.util.CommonConstants;
import smartbooksdb.hibernatebean.Organization;
import smartbooksdb.hibernatebean.User;
import smartbooksdb.service.UserOrganizationMappingService;

/**
 *
 * @author Ankit
 */
public class UserOrganizationMappingManager implements CommonConstants {
    
    /**
     * It returns the user firstnames mapped to an organization id
     * @param orgId
     * @return firstnames
     */
    public static ArrayList<String> getActiveFirstnamesMappedToOrganization(long orgId) {
        ArrayList<String> firstnames = new ArrayList<String>();
        ArrayList<User> users;
        
        UserOrganizationMappingService uomService = new UserOrganizationMappingService();
        users = (ArrayList<User>)(uomService.getActiveUsersMappedToOrganization(orgId));
        for(User user : users) {
            firstnames.add(user.getFirstName());
        }
        
        return firstnames;
    }
    
    /**
     * It returns the organization names mapped to a userId
     * @param userId
     * @return orgNames
     */
    public static ArrayList<String> getActiveOrganizationNamesMappedToUser(long userId) {
        ArrayList<String> orgNames = new ArrayList<String>();
        ArrayList<Organization> organizations;
        
        UserOrganizationMappingService uomService = new UserOrganizationMappingService();
        organizations = (ArrayList<Organization>)(uomService.getActiveOrganizationMappedToUser(userId));
        for(Organization organization : organizations) {
            orgNames.add(organization.getOrgName());
        }
        
        return orgNames;
    }
}